﻿<cfsilent>

	<cfset sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice") />
	<cfset depId = sessionAdvice.getUserProp("teacherDepartment") />

    <cfset sql = "  SELECT a.institute_name,a.institute_id,
						   t_institute_type.classification,a.institute_short,
						   t_institute_type.classification_name,a.institute_english,
						   a.institute_pyidx,a.institute_address
					FROM t_institute a 
						 INNER JOIN t_institute_type ON a.classification = t_institute_type.classification 
					WHERE a.institute_id = :depId "/>
                    
    <cfset queryObj = new Query( datasource=application.dnsSlave ) />
    <cfset queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" )/>
    
	<cfset rs_department = queryObj.execute( sql=sql ).getResult()/>
  
    <cfset sql = "  SELECT a.group_id,a.auth_id,
						   a.tch_id,t_teacher.tch_name,
						   t_technical_position.tp_series 
					FROM t_institute_admin a 
						 INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
						 INNER JOIN t_technical_position on t_technical_position.tp_id = t_teacher.tp_id 
					WHERE a.institute_id = :depId 
					ORDER BY a.group_id ASC "/>
                    
    <cfset queryObj = new Query( datasource=application.dnsSlave ) />
    <cfset queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" )/>
    
	<cfset rs_admin = queryObj.execute( sql=sql ).getResult()/>
    
     <cfset sql = " SELECT a.sbj_id,a.sbj_name,
						   a.term_start,a.level_code,
						   b.learning_branch 
					FROM t_subject a 
						 INNER JOIN t_learning_branch b ON b.b_id = a.b_id 
					WHERE a.institute_id = :depId 
						  AND
						  a.sbj_direction = :SubjectDirection 
					ORDER BY a.level_code ASC ,a.term_start ASC ,a.sbj_name ASC "/>
                    
    <cfset queryObj = new Query( datasource=application.dnsSlave ) />
    <cfset queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" )/>
    <cfset queryObj.addParam( name="SubjectDirection", value='0', cfsqltype="cf_sql_char" )/>
    
	<cfset rs_subject = queryObj.execute( sql=sql ).getResult()/>

	<cfset event.setArg("pageTitle", "教学运行基础数据 - 行政建制 - 院系(部)概况 - " & rs_department.institute_name) />

	<cfset targetArgs = structNew() />
	<cfset structInsert(targetArgs, "DepID", rs_department.institute_id, true) />

	<cfset currentTab = event.getArg("TabID", "labSubject") />

	<cfset dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice") />

</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('planSchema')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学计划</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>院系(部)概况 - <cfoutput>#rs_department.institute_name#</cfoutput>
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labBaseInfo">class="active"</cfif> id="labBaseInfo" tabTarget="BaseInfo">院系基础信息</span>
						<span <cfif currentTab eq "labSubject">class="active"</cfif> id="labSubject" tabTarget="Subject">专业设置</span>
						<span <cfif currentTab eq "labAdminGroup">class="active"</cfif> id="labAdminGroup" tabTarget="AdminGroup">管理团队</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>				
				</script>
				
				<div id="BaseInfo" class="tabContent">
					
					<cfif currentTab eq "labBaseInfo">
						<div class="systemNotice">
							<h3><span class="img icon16x16 info"></span>院系基础数据已更新</h3>
							<p>在填写完整学院基础数据后, 你可以通过上面的标签切换, 分别查阅到学院下设的专业信息以及教学管理人员信息.</p>
						</div>
					</cfif>
					
					<form id="formEdit" onSubmit="javascript:return processVerfiyForm('formEdit');" class="formWrapper" method="post" action="<cfoutput>#buildURL('instituteUpdateDo')#</cfoutput>">
						
						<input type="hidden" name="InstituteID" value="<cfoutput>#rs_department.institute_id#</cfoutput>" />
						<input type="hidden" name="Classification" value="<cfoutput>#rs_department.classification#</cfoutput>" />
						
						
						<div class="label">
							<span class="req">*</span><b>部门正式名称</b>
							<input name="InstituteName" id="InstituteName" type="text" class="typeText" verification="required" maxlength="50" value="<cfoutput>#event.getArg('InstituteName', rs_department.institute_name)#</cfoutput>" />
						</div>

						<div class="label">
							<span class="req">*</span><b>简称</b>
							<input name="InstituteShortName" id="InstituteShortName" type="text" class="typeTextTiny" verification="required" maxlength="6" value="<cfoutput>#event.getArg('InstituteShortName', rs_department.institute_short)#</cfoutput>" />
						</div>
						
						<div class="label">
							<b>单位类别</b>
							<p><cfoutput>#rs_department.classification_name#</cfoutput></p>
						</div>
						
						<hr/>
						
						<div class="label">
							<b>英文名称</b>
							<input name="InstituteEnglish" id="InstituteEnglish" type="text" class="typeText typeEnglish" maxlength="180" value="<cfoutput>#event.getArg('InstituteEnglish', rs_department.institute_english)#</cfoutput>" />
						</div>
						
						<div class="label">
							<b>简拼</b>
							<input name="InstitutePinyin" id="InstitutePinyin" type="text" class="typeCode" maxlength="6" value="<cfoutput>#event.getArg('InstitutePinyin', rs_department.institute_pyidx)#</cfoutput>" />
							<p class="notice">请填写单位简称的拼音首字母, 如果保留空值, 系统将自动根据汉语拼音读音生成. 如果简称中包含多音字, 拼音首字母可能不准确.</p>
						</div>
						
						<div class="label">
							<b>办公地址</b>
							<input name="InstituteAddress" id="InstituteAddress" type="text" class="typeText" maxlength="30" value="<cfoutput>#event.getArg('InstituteAddress',rs_department.institute_address)#</cfoutput>" />
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
							<input class="button" type="reset" value="重设表格" />
						</div>
						
					</form>
					
					
				</div>
				
				<div id="Subject" class="tabContent">

					<cfif rs_subject.recordCount>
							<div class="noticeBlock">
								<div class="operation">
									<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('subjectDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载专业设置信息</span></a>
									<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('classDepartmentDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载班级信息</span></a>
								</div>
								<h3>招生专业</h3>
								<p><span class="img icon16x16 message"></span>这里列出的是<cfoutput>#rs_department.institute_name#</cfoutput>下设的招生专业</p>
								<hr/>
							</div>
					
							
							
							<div class="clearfix">
								<div class="UICardTable">
                                    	<cfloop query="rs_subject">
										<cfset structInsert(targetArgs, "SubID", rs_subject.sbj_id, true) />
										<dl>
											<dt>
												<a href="<cfoutput>#buildURL('subjectSetting', targetArgs)#</cfoutput>">
													<em class="subject"><!--imgholder--></em>
													<dd>
														<h3><cfoutput>#rs_subject.sbj_name#</cfoutput></h3>
														<div><cfoutput>#dictAdvice.getTermEnrol(rs_subject.term_start)#-#dictAdvice.getStudentLevel(rs_subject.level_code)#(#rs_subject.learning_branch#)</cfoutput></div>
													</dd>
												</a>
											</dt>
										</dl>
									</cfloop>
								</div>
							</div>
						<cfelse>
							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>没有设置任何专业信息</h3>
								<p>当前您还没有设置<cfoutput>#rs_department.institute_name#</cfoutput>下属的专业信息, 请通过完善下列表单设置该学院的第一个招生专业.</p>
							</div>
					</cfif>

					
				</div>
				
				<div id="AdminGroup" class="tabContent">
					
					<cfset adminGroupList = "" />
					<cfset targetGroupList = "AD01, AD11, AD21" />
					
                    <cfloop query="rs_admin" >
                    
						<cfif listFindNoCase(targetGroupList, rs_admin.group_id, " ,") AND (not ListFind(adminGroupList, rs_admin.group_id))>
							<cfset adminGroupList = listAppend(adminGroupList, rs_admin.group_id) />
						</cfif>
					</cfloop>
										
					<cfif listLen(adminGroupList)>
							
							<div class="noticeBlock">
								<h3>学院教学管理团队</h3>
								<p><span class="img icon16x16 message"></span>这里列出的是<cfoutput>#rs_department.institute_name#</cfoutput>的教学管理团队. 如果您需要授权新的老师加入管理团队, <a href="javascript:showAuthFrom();">可以通过点击这里进行</a></p>
								<hr/>
							</div>
					
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								function showAuthFrom() {
									$("form#formSearch").toggleClass("hidden_elem");
									$("ul#gridAuth").toggleClass("hidden_elem");
									$("div#formSearchResult").addClass("hidden_elem");
									$("form#formAuth").addClass("hidden_elem");
									return void(0);
								}
								// -->
								//]]>				
							</script>
							
							
							<ul id="gridAuth" class="groupUser">
								<cfloop list="#adminGroupList#" index="group">
								<li>
									<div class="clearfix" id="group<cfoutput>#group#</cfoutput>">
										<cfswitch expression="#group#">
											<cfcase value="AD01"><h2>主管教学院长</h2></cfcase>
											<cfcase value="AD11"><h2>教学管理主任</h2></cfcase>
											<cfcase value="AD21"><h2>教学秘书</h2></cfcase>
										</cfswitch>
										<div class="clearfix">
                                            <cfloop query="rs_admin" >
												<cfif rs_admin.group_id eq group>
													<cfset structInsert(targetArgs, "AUTH", rs_admin.auth_id, true) />
													<cfset structInsert(targetArgs, "GroupID", rs_admin.group_id, true) />
													<cfset structInsert(targetArgs, "TeacherID", rs_admin.tch_id, true) />
													<div class="UISmallUserCard">
														<div class="cardContent"> 
															<img class="img" src="<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/graphic/userSmall.png" style="background-image: url('<cfoutput>#getContextRoot()#</cfoutput>/acadmicManager/teacher/portrait/<cfoutput>#rs_admin.tch_id#</cfoutput>.jpg');">
															<div class="cardDetail">
																<h3><cfoutput>#rs_admin.tch_name# <span class="uid">(#rs_admin.tch_id#)</span></cfoutput><a href="<cfoutput>#buildURL('instituteAdminRemoveDo', targetArgs)#</cfoutput>" class="kill"><!--.--></a></h3>
																<p><cfoutput>#rs_admin.tp_series#</cfoutput></p>
																
															</div>
														</div>
													</div>
												</cfif>
											</cfloop>
										</div>
									</div>
								</li>
								</cfloop>
							</ul>
							
						<cfelse>
							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>没有建立部门管理团队</h3>
								<p>当前您还没有设置<cfoutput>#rs_department.institute_name#</cfoutput>的教学管理团队, 请通过完善下列表单设置学院的管理团队.</p>
							</div>
					</cfif>
					
					<div id="teacherGrid">
						
						<form id="formSearch" class="formWrapper Transparent <cfif listLen(adminGroupList)>hidden_elem</cfif>" method="post">
							<div class="label">
								<b>教师姓名或职工号</b>
								<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
							</div>
							<hr/>
							<div class="lable">
								<input class="button1" type="submit" value="搜索教师" />
								<input id="formSearchReset" class="button" type="button" value="返回" />
							</div>
						</form>
						
						<div id="formSearchResult" class="UICardTable">
						</div>
						
						<form id="formAuth" class="formWrapper hidden_elem" method="post" action="<cfoutput>#buildURL('instituteAdminCreateDo')#</cfoutput>">
							
							<input type="hidden" name="InstituteID" value="<cfoutput>#rs_department.institute_id#</cfoutput>" />

							<div class="label">
								<b>职工号</b>
								<input readonly name="TeacherID" id="TeacherID" type="text" class="typeTextReadOnly" verification="required" value="" />
							</div>
							<div class="label">
								<b>教师</b>
								<input readonly name="TeacherName" id="TeacherName" type="text" class="typeTextReadOnly" verification="required" value="" />
							</div>
							<div class="label">
								<b>管理团队角色</b>
								<input name="GroupID" type="radio" class="typeRadio" value="AD01" />主管教学院长
								<input name="GroupID" type="radio" class="typeRadio" value="AD11" />教学管理主任
								<input name="GroupID" type="radio" class="typeRadio" checked="checked" value="AD21" />教学秘书
							</div>
							<hr/>
							<div class="lable">
								<input class="button" type="submit" value="授权" />
								<input id="formAuthReset" class="button" type="button" value="重新查找" />
							</div>
						</form>
						
						<script language="javascript" type="text/javascript">
							//<![CDATA[
							<!--
							$("input#formAuthReset").click(function(){
								$("form#formSearch").removeClass("hidden_elem");
								$("div#formSearchResult").removeClass("hidden_elem");
								$("form#formAuth").addClass("hidden_elem");
							});
							
							$("input#formSearchReset").click(function(){
								
								$("ul#gridAuth").removeClass("hidden_elem");
								
								$("form#formSearch").addClass("hidden_elem");
								$("div#formSearchResult").addClass("hidden_elem");
								$("form#formAuth").addClass("hidden_elem");
							});
							
							$("#formSearch").submit(function(){
								
								if (processVerfiyForm('formSearch')) {
									
									$.getJSON(
											'<cfoutput>#buildURL("getTeacherByKeywords")#</cfoutput>',
											{
												'Keywords': $("form#formSearch input#Keywords").val(),
												'seed': (new Date()).getTime()
											},
											function(data) {
												
												$div = $("div#formSearchResult").html("").removeClass("hidden_elem");
												$("form#formAuth").addClass("hidden_elem");
												
												for (var i=0; i<data.length; i++) {
											
													var $element = $("<dl><dt><a><i class='sex" + data[i][2] + "'></i><dd><h3>" + data[i][1] + " [" + data[i][3] + "]" + "</h3><p>(" + data[i][0] + ")</p></dd></a></dt></dl>");
													
													$element
														.attr({
															'TeacherID' : data[i][0],
															'TeacherName' : data[i][1]
														})
														.click(function(){
															
															var name = $(this).attr('TeacherName');
															var id = $(this).attr('TeacherID');
															
															$("form#formAuth input#TeacherID").val(id);
															$("form#formAuth input#TeacherName").val(name);
															
															$("form#formSearch").addClass("hidden_elem");
															$("div#formSearchResult").addClass("hidden_elem");
															$("form#formAuth").removeClass("hidden_elem");
													
														})
														.appendTo($div);
													
												}
												
											});
									
								}
							
								return false;
							});
							// -->
							//]]>
						</script>
						
					</div>

				</div>
				
				
				
			</div>
		</li>
	</ul>
</div>